package acc_synchronized;

/**
 * 方法上的synchronized和方法体中的synchronized的区别
 */
public class SyncDemo {
    static synchronized int s1() {
        return 0;
    }

    static int s2() {
        synchronized(SyncDemo.class) {
            return 0;
        }
    }

    synchronized int d1() {
        return 0;
    }

    int d2() {
        synchronized (this) {
            return 0;
        }
    }

    public static void main(String[] args) {
        System.out.println(s1());
        System.out.println(s2());

        SyncDemo demo = new SyncDemo();
        System.out.println(demo.d1());
        System.out.println(demo.d2());
    }
}
